﻿using DataAccessLayer.DatabaseOperations;
using MasterEntities.Abstraction;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccessLayer.Helper
{
    public class CommandTextGenerator : ICommandTextGenerator
    {
        IDomainObject m_DomainObject;
        AbstractExecutionTemplate m_ExecutionTemplate;
        CommandGenerationBehaviour m_CommGenerator;

        public CommandTextGenerator(AbstractExecutionTemplate executionTemplate, IDomainObject obj)
        {
            m_ExecutionTemplate = executionTemplate;
            m_DomainObject = obj;
        }

        public Dictionary<int, string> GetCommandText(IDomainObject obj)
        {
            if (m_ExecutionTemplate is Create)
                m_CommGenerator = new InsertText();
            else if (m_ExecutionTemplate is Update)
                m_CommGenerator = new UpdateText();
            else if (m_ExecutionTemplate is Delete)
                m_CommGenerator = new DeleteText();

            return m_CommGenerator.GetCommandText(obj);
        }
    }
}
